package com.hard;

/**
 * Created by Lxk on 2020/2/9.
 */
public class Solution154 {

    public int findMin(int[] nums) {
        int left = 0, right = nums.length - 1;
        while (left < right) {
            int mid = left + (right - left) / 2;
            if (nums[mid] < nums[right]) {
                right = mid;
            } else if (nums[mid] > nums[right]) {
                left = mid + 1;
            } else {
                right = right - 1;
            }
        }
        return nums[left];
    }

    public static void main(String[] args) {
        int[] arr = {2, 2, 2, 0, 0, 0, 0, 0};
        Solution154 solution154 = new Solution154();
        System.out.println(solution154.findMin(arr));
    }

}
